#ifndef _MFG_H
#define _MFG_H

#include "osal_port.h"
#include "zcl_port.h"
#include "zstack.h"
#include "util/mfg_zcl.h"

/* MACRO */

#define  MFG_CSState    uint32

#define  MFG_malloc        OsalPort_malloc
#define  MFG_free          OsalPort_free
#define  MFG_enterCS       OsalPort_enterCS
#define  MFG_leaveCS       OsalPort_leaveCS
#define  MFG_setEvent      OsalPort_setEvent
#define  MFG_startTimer    OsalPortTimers_startTimer
#define  MFG_random        OsalPort_rand

#define  MFG_LOAD_U16(p,w)   (*p=LO_UINT16(w),*(p+1)=HI_UINT16(w))
#define  MFG_SelfTaskId()    OsalPort_getTaskId(Task_self())

#define  MFG_Nv_Item_Init(id, len, buf)       zclport_initializeNVItem( ZCD_NV_EX_MFG, id, len, buf )
#define  MFG_Nv_Read(id, ndx, len, buf)       zclport_readNV( ZCD_NV_EX_MFG, id, ndx, len, buf )
#define  MFG_Nv_Write(id, len, buf)           zclport_writeNV( ZCD_NV_EX_MFG, id, len, buf )
#define  MFG_NV_Delete(id, len)               zclport_deleteNV( ZCD_NV_EX_MFG, id, len )

//MFG events
#define  MFG_MSG_IN_EVENT    0x4000
#define  MFG_CMD_RX_EVENT    0x2000
#define  MFG_CMD_TX_EVENT    0x1000
// Green Power Events
#define  MFG_GP_TEMP_MASTER_EVT            0x0800
#define  MFG_GP_EXPIRE_DUPLICATE_EVT       0x0400
#define  MFG_GP_DATA_SEND_EVT              0x0200
//
#define  MFG_PERIOD_EVENT                  0x0080  //every second
#define  MFG_SEQ_REC_EVENT                 0x0040  //
// Coord event

//MFG NV Item ID
#define ZCD_NV_EX_MFG                      0x0010

//MFG NV IDs




/* MACRO */


/* TYPEDEF*/
typedef uint8_t mfgDevSn_t[9];
typedef uint8_t mfgDevAddr_t[3];

#endif
